package com.example.quartzdemo.SpringTaskTestConfig.controller;

import com.example.quartzdemo.SpringTaskTestConfig.pojo.SysJobPO;
import com.example.quartzdemo.SpringTaskTestConfig.service.SysjonRunnerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @TODO
 * @ClassName MyTimeS
 * @Author 81373
 * @Date 2022/11/9 16:56
 */
@RequestMapping("/schedule")
@RestController
public class MyTimeS {

    @Autowired
    SysjonRunnerService sysjonRunnerService;

    // 实现调用
    @RequestMapping("/add")
    public Object addSchedule(){
        SysJobPO sysJobPO = new SysJobPO();
        sysJobPO.setJobId(1);
        sysJobPO.setJobStatus(1);
        sysJobPO.setRemark("第一个");
        sysJobPO.setCronExpression("0/2 * * * * ?");
        sysJobPO.setMethodName("testJob");
        sysJobPO.setMethodParams("6666");
        sysJobPO.setBeanName("jobTest");

        sysjonRunnerService.addScheduled(sysJobPO);
        // 直接返回结果
        return  "我已经加载完毕";
    }

    @RequestMapping("/editSysJob")
    public Object editSysJob(){

        SysJobPO sysJobPO = new SysJobPO();
        sysJobPO.setJobId(1);
        sysJobPO.setJobStatus(1);
        sysJobPO.setRemark("第er个");
        sysJobPO.setCronExpression("0/10 * * * * ?");
        sysJobPO.setMethodName("testJob");
        sysJobPO.setMethodParams("777");
        sysJobPO.setBeanName("jobTest");

        sysjonRunnerService.editSysJob(sysJobPO);
        // 直接返回结果
        return  "我已经访问完毕";
    }


}
